class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  has_many :user_role_relations, dependent: :destroy
  has_many :roles, through: :user_role_relations
  has_many :part_purchases
  has_many :order_maintains
  has_many :order_beauties
  has_many :part_stockins
  has_many :part_stockouts
  has_many :part_salses
  has_many :customer_reviews


  def has_role(name)
    roles.find_by_name(name)
  end

end
